package speed2010.andreza.vspeed.gui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;

/**
 * @author <a href="mailto:andreza.lba@gmail.com">Andreza Leite de Alencar</a>
 */
public class ISPEEDGUI extends javax.swing.JFrame {

	private static final long serialVersionUID = 1L;

	public JMenuItem jMenuItemSparQL;
	JMenuItem jMenuItemVisualQuery;
	public JMenu jMenuQuery;
	public JMenuItem jMenuItemExit;
	private JSeparator jSeparator2;
	public JMenuItem jMenuItemParticipatingPeers;
	public JMenuItem jMenuItemTheSystem;
	private JMenu jMenuHome;
	private JMenuBar jMenuBar1;
	private JLabel jLabelSpeed;
	private JPanel jContentPanel;
	public JMenuItem jMenuItemJavadoc;
	public JMenuItem jMenuItemUserGuide;
	private JMenu jMenuDocumentation;
	public JMenuItem jMenuItemViewNetwork;
	public JMenuItem jMenuItemJoinNetwork;
	public JMenuItem jMenuItemChoosePeer;
	private JMenu jMenuNetwork;


	public ISPEEDGUI() {
		super();
		GUIConstants.GUI_INSTANCE = this;
		setTitle(GUIConstants.TITLE);
		setIconImage(GUIConstants.Images.MAIN_ICON);
		setMinimumSize(new Dimension(800, 600));
		initGUI();
	}

	private void initGUI() {
		try {
			{
				this.jContentPanel = new JPanel();
				getContentPane().add(this.jContentPanel, BorderLayout.CENTER);
				final BorderLayout jPanel1Layout = new BorderLayout();
				this.jContentPanel.setLayout(jPanel1Layout);
				this.jContentPanel.setBackground(new java.awt.Color(255, 255, 255));
				{
					this.jLabelSpeed = new JLabel();
					this.jContentPanel.add(this.jLabelSpeed, BorderLayout.CENTER);
					this.jLabelSpeed.setIcon(GUIConstants.Images.IMAGE_SPEED);
					this.jLabelSpeed.setHorizontalAlignment(SwingConstants.CENTER);
					this.jLabelSpeed.setVerticalAlignment(SwingConstants.CENTER);
				}
			}
			this.setSize(1024, 768);
			{
				this.jMenuBar1 = new JMenuBar();
				setJMenuBar(this.jMenuBar1);
				{
					this.jMenuHome = new JMenu();
					this.jMenuBar1.add(this.jMenuHome);
					this.jMenuHome.setText(GUIConstants.MENU_HOME);
					this.jMenuHome.setFont(this.jMenuHome.getFont().deriveFont(Font.BOLD));
					this.jMenuHome.setIcon(GUIConstants.Images.ICON_HOME);
					{
						this.jMenuItemParticipatingPeers = new JMenuItem();
						this.jMenuHome.add(this.jMenuItemParticipatingPeers);
						this.jMenuItemParticipatingPeers.setText(GUIConstants.MENU_HOME_PEERS);
						this.jMenuItemParticipatingPeers.addActionListener(Events.LISTENER);
					}
					{
						this.jSeparator2 = new JSeparator();
						this.jMenuHome.add(this.jSeparator2);
					}
					{
						this.jMenuItemExit = new JMenuItem();
						this.jMenuHome.add(this.jMenuItemExit);
						this.jMenuItemExit.setText(GUIConstants.MENU_HOME_EXIT);
						this.jMenuItemExit.addActionListener(Events.LISTENER);
					}
				}
				{
					this.jMenuQuery = new JMenu();
					this.jMenuBar1.add(this.jMenuQuery);
					this.jMenuQuery.setText(GUIConstants.MENU_QUERY);
					this.jMenuQuery.setFont(this.jMenuQuery.getFont().deriveFont(Font.BOLD));
					this.jMenuQuery.setIcon(GUIConstants.Images.ICON_QUERY);
					this.jMenuQuery.addMouseListener(Events.MOUSE_LISTENER);
					{
						this.jMenuItemVisualQuery = new JMenuItem();
						this.jMenuQuery.add(this.jMenuItemVisualQuery);
						this.jMenuItemVisualQuery.setText(GUIConstants.MENU_QUERY_VISUAL);
						this.jMenuItemVisualQuery.addActionListener(Events.LISTENER);
					}
					{
						this.jMenuItemSparQL = new JMenuItem();
						this.jMenuQuery.add(this.jMenuItemSparQL);
						this.jMenuItemSparQL.setText(GUIConstants.MENU_QUERY_SPARQL);
						this.jMenuItemSparQL.addActionListener(Events.LISTENER);
					}
				}
				{
					this.jMenuNetwork = new JMenu();
					this.jMenuBar1.add(this.jMenuNetwork);
					this.jMenuNetwork.setText(GUIConstants.MENU_NETWORK);
					this.jMenuNetwork.setFont(this.jMenuNetwork.getFont().deriveFont(Font.BOLD));
					this.jMenuNetwork.setIcon(GUIConstants.Images.ICON_NETWORK);
					{
						this.jMenuItemViewNetwork = new JMenuItem();
						this.jMenuItemViewNetwork.setText(GUIConstants.MENU_NETWORK_VIEW);
						this.jMenuItemViewNetwork.addActionListener(Events.LISTENER);

						this.jMenuItemJoinNetwork = new JMenuItem();
						this.jMenuItemJoinNetwork.setText(GUIConstants.MENU_NETWORK_JOIN);
						this.jMenuItemJoinNetwork.addActionListener(Events.LISTENER);

						this.jMenuItemChoosePeer = new JMenuItem();
						this.jMenuItemChoosePeer.setText(GUIConstants.MENU_NETWORK_CHOOSE);
						this.jMenuItemChoosePeer.addActionListener(Events.LISTENER);
						
						this.jMenuNetwork.add(this.jMenuItemViewNetwork);
						this.jMenuNetwork.add(this.jMenuItemJoinNetwork);
						//this.jMenuNetwork.add(this.jMenuItemChoosePeer);
					}
				}
				{
					this.jMenuDocumentation = new JMenu();
					this.jMenuBar1.add(this.jMenuDocumentation);
					this.jMenuDocumentation.setText(GUIConstants.MENU_DOCUMENTATION);
					this.jMenuDocumentation.setFont(this.jMenuDocumentation.getFont().deriveFont(Font.BOLD));
					this.jMenuDocumentation.setIcon(GUIConstants.Images.ICON_DOCUMENTATION);
					{
						this.jMenuItemUserGuide = new JMenuItem();
						this.jMenuDocumentation.add(this.jMenuItemUserGuide);
						this.jMenuItemUserGuide.setText(GUIConstants.MENU_DOCUMENTATION_USERGUIDE);
						this.jMenuItemUserGuide.addActionListener(Events.LISTENER);
					}
					{
						this.jMenuItemJavadoc = new JMenuItem();
						this.jMenuDocumentation.add(this.jMenuItemJavadoc);
						this.jMenuItemJavadoc.setText(GUIConstants.MENU_DOCUMENTATION_JAVADOC);
						this.jMenuItemJavadoc.addActionListener(Events.LISTENER);
					}
					{
						this.jMenuItemTheSystem = new JMenuItem();
						this.jMenuDocumentation.add(this.jMenuItemTheSystem);
						this.jMenuItemTheSystem.setText(GUIConstants.MENU_DOCUMENTATION_SYSTEM);
						this.jMenuItemTheSystem.addActionListener(Events.LISTENER);
					}
				}
			}
		} catch (final Exception e) {
			e.printStackTrace();
		}
	}

	public void changePanel(final JPanel jPanel) {
		invalidate();
		setContentPane(jPanel);
		validate();
		this.repaint();
	}
}
